import { useState, useEffect } from 'react'
import { getChannelApi } from '@/apis/article'

function useChannel () {
  // 1.获取平道列表
  //获取频道列表
  const [channelList, setChannelList] = useState([])
  useEffect(() => {
    //封装函数
    const getChannelList = async () => {
      const res = await getChannelApi()
      setChannelList(res.data.channels)
    }
    //调用函数
    getChannelList()
  }, [])
  // 2.把组件用到的return数据返回
  return {
    channelList
  }
}
export { useChannel }